package com.googlecode.asm_ide.compiler;

import java.io.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Philipp Hell <philipp@hell.info>
 */
public class NASM implements Compiler{

    private final String name = "NASM";
    private Process process;
    private ArrayList<String> consoleOutput, errorOutput;

    public NASM() {
        consoleOutput = new ArrayList<String>();
        errorOutput = new ArrayList<String>();
    }
    
    @Override
    public void compile(File f) {
        try {
            String line;
            process = Runtime.getRuntime().exec("ls -a");
            BufferedReader bro = new BufferedReader(new InputStreamReader(process.getInputStream()));
            BufferedReader bre = new BufferedReader(new InputStreamReader(process.getErrorStream()));
            while((line = bro.readLine()) != null){
                consoleOutput.add(line);
            }
            bro.close();
            while((line = bre.readLine()) != null){
                errorOutput.add(line);
            }
            bre.close();
        } catch (IOException ex) {
            Logger.getLogger(NASM.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    @Override
    public String getName() {
        return this.name;
    }
    
    @Override
    public ArrayList<String> getConsoleOutput(){
        return consoleOutput;
    }

    @Override
    public ArrayList<String> getErrorOutput() {
        return errorOutput;
    }
    
    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String toString() {
        return this.getName();
    }
}